import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
import {UploadTypeEnum} from "@/components/Form/src/jeecg/components/JUpload";
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '文件名',
    align:"center",
    dataIndex: 'fileName'
   },
   {
    title: '文件路径',
    align:"center",
    dataIndex: 'filePath',
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "文件名",
      field: 'fileName',
      component: 'Input',
      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '文件路径',
    field: 'filePath',
    component: 'JUpload',
    componentProps:({formActionType})=>{
      return{
        maxCount:1,
        fileType:UploadTypeEnum.file,
        returnUrl:false,
        onChange:(res)=>{
          let t = JSON.parse(res)
          console.log(t[0].fileName)

          formActionType.setFieldsValue({
            fileName:t[0].fileName,
            fileSize:t[0].fileSize,
            filePath:t[0].filePath,
          })
        }
      }

    },
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入文件路径!'},
      ];
    },
  },
  {
    label: '文件名',
    field: 'fileName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入文件名!'},
          ];
     },
  },

	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
  {
    label: '',
    field: 'fileSize',
    component: 'Input',
    show: false
  }
];

// 高级查询数据
export const superQuerySchema = {
  fileName: {title: '文件名',order: 0,view: 'text', type: 'string',},
  filePath: {title: '文件路径',order: 1,view: 'file', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
